package com.itheima.d6_object_stream;

import java.io.*;

/*
  目标：掌握对象字节输入流的使用：反序列化对象。
 */
public class Test2ObjectInputStream {

    public static void main(String[] args) {
        // 读取
        try {
            readObject();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }

    }

    public static void readObject() throws IOException, ClassNotFoundException {
        // 1. 创建流对象
        final ObjectInputStream oiw = new ObjectInputStream(new FileInputStream("object.oxt"));


        // 2. 写入数据
        final Student student = (Student) oiw.readObject();
        System.out.println(student);


        // 3. 关闭流
        oiw.close();
    }
}
